<template>
  <div
    v-loading.fullscreen.lock="fullscreenLoading"
    element-loading-text="Loading..."
  >
    <el-dialog
      v-model="opens"
      fullscreen
      :close-on-click-modal="false"
      :title="title"
    >
      <el-form
        ref="updateForms"
        inline
        label-width="120px"
        class="queryParams"
        :model="updateForm"
      >
        <el-row>
          <!-- <el-col :span="24"> -->
          <!-- <el-row> -->
          <el-col :span="24" class="mb8">
            <div>基本信息</div>
          </el-col>
          <!-- <el-col :span="24"> -->
          <el-form-item label="系统订单号" prop="orderNo" disabled>
            <el-input
              v-model="updateForm.orderNo"
              style="width: 140px;"
              size="small"
              disabled
            ></el-input>
          </el-form-item>
          <el-form-item label="报价类型" prop="quotationType">
            <el-select
              v-model="updateForm.quotationType"
              filterable
              size="small"
              disabled
              @change="checkpiece"
            >
              <el-option
                v-for="dict in dicts[DictDirection.报价类型]"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item v-if="updateForm.quotationType != 3" :label="labels" prop="customPrice">
            <el-input v-model="updateForm.customPrice" disabled size="small"></el-input>
          </el-form-item>
          <el-form-item label="签入员" prop="checkInMer">
            <el-input v-model="updateForm.checkInMer" disabled size="small"></el-input>
          </el-form-item>
          <el-form-item label="业务员：" prop="businessManager">
            <el-input v-model="updateForm.businessManager" disabled size="small"></el-input>
          </el-form-item>
          <el-form-item label="订单状态：" prop="splittingStatus" :formatter="(row) => dicts.getDictLabel({ dict: DictDirection.包裹状态, value: row.splittingStatus })">
            <el-select
              v-model="updateForm.splittingStatus"
              filterable
              disabled
              size="small"
            >
            </el-select>
          </el-form-item>
          <el-form-item label="主转单号：" prop="mainTransferOrderNo">
            <el-input v-model="updateForm.mainTransferOrderNo" :disabled="title=='详情'" size="small">
              <i @click="mainTransferOrderNoDialogVisible= true">11</i>
            </el-input>
          </el-form-item>
          <el-form-item label="子转单号：" prop="transferOrderNo">
            <el-input v-model="updateForm.transferOrderNo" :disabled="title=='详情'" size="small">
              <i @click="transferOrderNoDialogVisible = true">11</i>
            </el-input>
          </el-form-item>
          <el-form-item label="备注：" style="width: 560px;" prop="remarks">
            <el-input
              v-model="updateForm.remarks"
              style="width: 397px;"
              size="small"
              :disabled="title=='详情'"
              type="textarea"
            ></el-input>
          </el-form-item>
          <span v-if="title=='修改'" class="notes">如果对应收费用信息有操作,请在备注栏加上备注</span>
          <el-divider></el-divider>

          <el-col :span="24">
            <el-row>
              <el-col :span="24">
                <el-row>
                  <el-col :span="24" class="mb8">收货信息</el-col>
                  <el-col :span="24">
                    <el-form-item label="客户简称" prop="customerCode">
                      <el-input v-model="updateForm.customerCode" disabled size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="收货类型：" prop="goodsType">
                      <el-select
                        v-model="updateForm.goodsType"
                        filterable
                        disabled
                        size="small"
                      >
                        <el-option
                          v-for="dict in dicts[DictDirection.包裹类型]"
                          :key="dict.dictValue"
                          :label="dict.dictLabel"
                          :value="dict.dictValue"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="收货时间：" prop="orderTime">
                      <el-date-picker
                        v-model="updateForm.orderTime"
                        disabled
                        type="date"
                        size="small"
                        style="width: 135px;"
                        placeholder=""
                        format="YYYY-MM-DD"
                        value-format="YYYY-MM-DD"
                      ></el-date-picker>
                    </el-form-item>
                    <el-form-item label="总计实重：" prop="receivingTotalWeight">
                      <el-input v-model="updateForm.receivingTotalWeight" disabled size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="总体积重：" prop="receivingTotalWood">
                      <el-input v-model="updateForm.receivingTotalWood" disabled size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="总计费重：" prop="receivingTotalCharging">
                      <el-input v-model="updateForm.receivingTotalCharging" size="small" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="总件数：" prop="receivingTotal">
                      <el-input v-model="updateForm.receivingTotal" size="small" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="收货材积系数：" prop="receivingWoodCoefficient">
                      <el-input v-model="updateForm.receivingWoodCoefficient" size="small" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="收货体积系数：" prop="receivingVolumeCoefficient">
                      <el-input v-model="updateForm.receivingVolumeCoefficient" size="small" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="收货计重规则：" prop="receivingWeightRule">
                      <el-select
                        v-model="updateForm.receivingWeightRule"
                        filterable
                        size="small"
                        placeholder=""
                        disabled
                      >
                        <el-option
                          v-for="dict in dicts[DictDirection.计重规则]"
                          :key="dict.dictValue"
                          :value="dict.dictValue"
                          :label="dict.dictLabel"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-divider></el-divider>
              </el-col>
              <el-col :span="24">
                <el-row>
                  <el-col :span="24" class="mb8">出货信息</el-col>
                  <el-col :span="24">
                    <el-form-item label="客户单号：" prop="waybillNo">
                      <el-input v-model="updateForm.waybillNo" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="出货时间：" prop="shipmentTime">
                      <el-date-picker
                        v-model="updateForm.shipmentTime"
                        type="date"
                        size="small"
                        style="width: 155px;"
                        placeholder=""
                        format="YYYY-MM-DD"
                        value-format="YYYY-MM-DD"
                      ></el-date-picker>
                    </el-form-item>
                    <el-form-item label="总计实重：" prop="shipmentTotalWeight">
                      <el-input v-model="updateForm.shipmentTotalWeight" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="总体积重：" prop="shipmentTotalWood">
                      <el-input v-model="updateForm.shipmentTotalWood" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="总计费重：" prop="shipmentTotalCharging">
                      <el-input v-model="updateForm.shipmentTotalCharging" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="总件数：" prop="shipmentTotal">
                      <el-input v-model="updateForm.shipmentTotal" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="成本金额：" prop="payableAmount">
                      <el-input v-model="updateForm.payableAmount" :controls="false" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="清关时间：" prop="clearanceTime">
                      <el-date-picker
                        v-model="updateForm.clearanceTime"
                        type="date"
                        size="small"
                        style="width: 135px;"
                        placeholder="选择日期"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-divider></el-divider>
          </el-col>
          <el-col :span="24">
            <el-row>
              <el-col :span="24">
                <el-row>
                  <el-col :span="24" class="mb8">收件人信息</el-col>
                  <el-col :span="24">
                    <el-form-item label="国家：" prop="consigneeCountry">
                      <el-select
                        v-model="updateForm.consigneeCountry"
                        size="small"
                        style="width: 200px;"
                        placeholder="请输入内容"
                      >
                        <el-option
                          v-for="dict in dicts[DictDirection.国家]"
                          :key="dict.countryCode"
                          :label="dict.countryChName"
                          :value="dict.countryCode"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="姓名：" prop="consigneeName">
                      <el-input v-model="updateForm.consigneeName" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="邮编：" prop="consigneePostcode">
                      <el-input v-model.trim="updateForm.consigneePostcode" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="公司：" prop="consigneeCompany">
                      <el-input v-model="updateForm.consigneeCompany" auto-complete="on" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="城市：" prop="consigneeCity">
                      <el-input v-model="updateForm.consigneeCity" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="省州：" prop="provinceStateCode">
                      <el-input v-model="updateForm.provinceStateCode" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="电话：" prop="consigneeTel">
                      <el-input v-model="updateForm.consigneeTel" auto-complete="on" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="地址1：" prop="consigneeAddress">
                      <el-input
                        v-model="updateForm.consigneeAddress"
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 4 }"
                        size="small"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="地址2：" prop="consigneeAddress2">
                      <el-input
                        v-model="updateForm.consigneeAddress2"
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 4 }"
                        size="small"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-divider></el-divider>
          </el-col>

          <el-col :span="24">
            <el-row>
              <el-col>包裹信息</el-col>
              
              <el-col :span="24">
                <el-button
                  v-if="title=='修改'"
                  :icon="Plus"
                  type="primary"
                  text
                  size="small"
                  @click="handleAddPackage"
                >
                  添加包裹
                </el-button>
              </el-col>
              <!-- <el-table
                  ref="table"
                  border
                  :data="updateForm.receivingWoodInfo"
                  height="400"
                  :summary-method="getSummaries"
                  show-summary
                >
                  <el-table-column
                    label="序号"
                    align="center"
                    type="index"
                    width="50"
                  ></el-table-column>
                  <el-table-column label="箱号" align="center" prop="caseNumber">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.caseNumber`"
                      >
                        <el-input
                          v-model="row.caseNumber"
                          style="width: 100%;"
                          :controls="false"
                          disabled
                        >
                        </el-input>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="长(cm)" align="center" prop="length">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.length`"
                      >
                        <el-input-number
                          v-model="row.length"
                          style="width: 100%;"
                          :controls="false"
                        >
                        </el-input-number>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="宽(cm)" align="center" prop="width">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.width`"
                      >
                        <el-input-number
                          v-model="row.width"
                          style="width: 100%;"
                          :controls="false"
                        >
                        </el-input-number>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="高(cm)" align="center" prop="height">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.height`"
                      >
                        <el-input-number
                          v-model="row.height"
                          style="width: 100%;"
                          :controls="false"
                        >
                        </el-input-number>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="实重(kg)" align="center" prop="weight">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.weight`"
                      >
                        <el-input-number
                          v-model="row.weight"
                          style="width: 100%;"
                          :controls="false"
                        >
                        </el-input-number>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="计费重" align="center" prop="jWeight">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.jWeight`"
                      >
                        <el-input-number
                          v-model="row.jWeight"
                          style="width: 100%;"
                          :controls="false"
                        >
                        </el-input-number>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="材积重" align="center" prop="vWeight">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.vWeight`"
                      >
                        <el-input-number
                          v-model="row.vWeight"
                          style="width: 100%;"
                          :controls="false"
                        >
                        </el-input-number>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="件数" align="center" prop="pieceNumber">
                    <template #default="{ row, $index }">
                      <el-form-item
                        :prop="`receivingWoodInfo.${$index}.pieceNumber`"
                      >
                        <el-input-number
                          v-model="row.pieceNumber"
                          style="width: 100%;"
                          :controls="false"
                        >
                        </el-input-number>
                      </el-form-item>
                    </template>
                  </el-table-column>
                </el-table> -->
              <el-col :span="24" class="mb8" style="height: 445px;">
                <vxe-grid
                  ref="xGrid"
                  v-bind="gridOptions1"
                  :data="tabledata"
                  height="400"
                >
                  <template #caseNumber_edit="{ row }">
                    <vxe-input v-model="row.caseNumber"></vxe-input>
                  </template>
                  <template #length_edit="{ row }">
                    <vxe-input v-model="row.length"></vxe-input>
                  </template>
                  <template #width_edit="{ row }">
                    <vxe-input v-model="row.width"></vxe-input>
                  </template>
                  <template #height_edit="{ row }">
                    <vxe-input v-model="row.height"></vxe-input>
                  </template>
                  <template #weight_edit="{ row }">
                    <vxe-input v-model="row.weight"></vxe-input>
                  </template>
                  <template #jWeight_edit="{ row }">
                    <vxe-input v-model="row.jWeight"></vxe-input>
                  </template>
                  <template #vWeight_edit="{ row }">
                    <vxe-input v-model="row.vWeight"></vxe-input>
                  </template>
                  <template #site_edit="{ row }">
                    <vxe-input v-model="row.site"></vxe-input>
                  </template>
                  <template #status_edit="{ row }">
                    <vxe-input v-model="row.status"></vxe-input>
                  </template>
                  <template v-if="title=='修改'" #operate="{ row}">
                    <vxe-button
                      title="删除"
                      label="删除"
                      circle
                      @click="removeRowEvent(row)"
                    >
                      删除
                    </vxe-button>
                  </template>
                </vxe-grid>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="24">
            <el-row>
              <el-col :span="24">
                <div class="mb8">货物追踪详细信息</div>
              </el-col>
              <el-col :span="24" class="myScrollbar">
                <el-table :data="trajectoryList" max-height="500px" border>
                  <el-table-column align="center" label="原始轨迹" prop="operationAction"></el-table-column>
                  <el-table-column align="center" label="日期" prop="operatorDate"></el-table-column>
                  <el-table-column align="center" label="操作人" prop="operatorUser"></el-table-column>
                  <el-table-column align="center" label="轨迹内容" prop="operableTrack">
                    <!-- <template #default="{ row }">
                      <el-popover
                        v-model="row.visible"
                        placement="top"
                        width="400"
                        @show="updateName(row)"
                      >
                        <el-form :model="nameForm" inline>
                          <el-form-item prop="operableTrack">
                            <el-input
                              v-model="nameForm.operableTrack"
                              style="width: 335px;"
                              clearable
                              type="textarea"
                              autosize
                            ></el-input>
                          </el-form-item>
                          <el-form-item>
                            <el-button type="primary" @click="submitEditName(row)">修改</el-button>
                            <el-button @click="row.visible = false">取消</el-button>
                          </el-form-item>
                        </el-form>
                        <el-button text>
                          {{ row.operableTrack || "无数据" }}
                        </el-button>
                      </el-popover>
                    </template> -->
                  </el-table-column>
                  <el-table-column
                    label="备注"
                    align="center"
                    prop="remarks"
                    show-overflow-tooltip
                  ></el-table-column>
                </el-table>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </el-form>
      <div class="footer">
        <el-button
          v-if="title=='修改'"
          type="primary"
          :loading="confirmLoading"
          @click="handleEdit"
        >
          确定
        </el-button>
        <el-button type="info" @click="cancel">取消</el-button>
      </div>
    </el-dialog>
			
    <!-- 打开主转单号对话框 -->
    <el-dialog
      v-model="mainTransferOrderNoDialogVisible"
      :close-on-click-modal="false"
      title="转单号"
      width="30%"
      append-to-body
    >
      <el-input
        v-model="updateForm.mainTransferOrderNo"
        :rows="14"
        type="textarea"
        placeholder="请输入内容"
      ></el-input>
    </el-dialog>
    <!-- 打开子转单号 -->
    <el-dialog
      v-model="transferOrderNoDialogVisible"
      :close-on-click-modal="false"
      title="转单号"
      width="30%"
      append-to-body
    >
      <el-input
        v-model="updateForm.transferOrderNo"
        :rows="14"
        type="textarea"
        placeholder="请输入内容"
      ></el-input>
    </el-dialog>
  </div>
</template>
<script lang='ts' setup>
import { Plus } from '@element-plus/icons-vue'
import { ref, getCurrentInstance } from 'vue'
import { ElButton, ElMessage, ElMessageBox } from 'element-plus'
import { VxeGridInstance, VXETable } from 'vxe-table'
import useDicts, { DictDirection } from '@/store/modules/dicts'
import { getOrderDetail, listTable, updateOverseasWarehouse, queryPackageDetailsList } from '@/api/expressManager/outSea'

const fullscreenLoading = ref(false)
const { proxy } = getCurrentInstance() as any
const dicts = useDicts()
dicts.setDicts(DictDirection.国家)
dicts.setDicts(DictDirection.报价类型)
dicts.setDicts(DictDirection.包裹类型)
dicts.setDicts(DictDirection.计重规则)
const updateForms = ref(null), {
  appContext: {
    config: {
      globalProperties: { $validateForm },
    },
  },
} = getCurrentInstance()
const labels = ref(null)
const loading = ref(true)
const opens = ref(false)
const title = ref(null)
const updateForm = ref({
  orderNo: '',
  quotationType: '',
  customPrice: '',
  checkInMer: '',
  businessManager: '',
  splittingStatus: '',
  mainTransferOrderNo: '',
  transferOrderNo: '',
  remarks: '',
  customerCode: '',
  goodsType: '',
  orderTime: '',
  receivingTotalWeight: '',
  receivingTotalWood: '',
  receivingTotalCharging: '',
  receivingTotal: '',
  receivingWoodCoefficient: '',
  receivingVolumeCoefficient: '',
  receivingWeightRule: '',
  waybillNo: '',
  shipmentTime: '',
  shipmentTotalWeight: '',
  shipmentTotalWood: '',
  shipmentTotalCharging: '',
  shipmentTotal: '',
  payableAmount: '',
  clearanceTime: '',
  consigneeCountry: '',
  consigneeName: '',
  consigneePostcode: '',
  consigneeCompany: '',
  consigneeCity: '',
  provinceStateCode: '',
  consigneeTel: '',
  consigneeAddress: '',
  consigneeAddress2: '',
  deletePackageIdList: [],
  packageDetailsInfo: [],
  // receivingWoodInfo: [],
})
const checkpiece = () => {
  const ss = updateForm.value.quotationType
  console.log(ss)
  
  if (ss == '1') {
    labels.value = '单价'
    console.log(1)
  }
  if (ss == '2') {
    console.log(2)
    labels.value = '总价'
  }
  if (ss == '4') {
    labels.value = '立方总价'
    console.log(labels.value)
  }
  if (ss == '3') {
    updateForm.value.customPrice = ''
  }
}
// const table = ref(null)
const tabledata = ref({
  caseNumber: '',
  length: '',
  width: '',
  height: '',
  weight: '',
  jWeight: '',
  vWeight: '',
  site: '',
  status: '',
})
const trajectoryList = ref([])
const mainTransferOrderNoDialogVisible = ref(false)
const transferOrderNoDialogVisible = ref(false)
const confirmLoading = ref(false)
const emit = defineEmits(['changeList'])
// const filterParams = (params) => {
//   // props为只想要params里面对象的参数
//   console.log(params)
  
//   const props = [
//     'caseNumber',
//     'length',
//     'width',
//     'height',
//     'weight',
//     'jWeight',
//     'vWeight',
//     'site',
//     'status',
//   ]
//   console.log(11)
  
//   const dataObj = {}
//   props.forEach(v => {
//     dataObj[v] = params[v]
//   })
//   console.log(dataObj)
//   return dataObj
// }
const handleEdit = () => {
  $validateForm(updateForms.value, () => {
    const tb = tabledata.value
    for (const i in tb) {
      delete tb[i]._X_ROW_KEY
      // delete tb[i].bweight
      // delete tb[i].deptId
      // delete tb[i].escapeHeavyClass
      // delete tb[i].ladingNo
      // delete tb[i].picUrl
      // delete tb[i].picUrlList
      // delete tb[i].pieceNumber
      // delete tb[i].transportTime
      // delete tb[i].upsClass
      // delete tb[i].userId
      // delete tb[i].waybillNo
      // delete tb[i].votesNumber
    }
    updateForm.value.deletePackageIdList = deletdId.value
    updateForm.value.packageDetailsInfo = tabledata.value
    confirmLoading.value = true
    updateOverseasWarehouse(updateForm.value).then(res => {
      if (res.code == 200) {
        ElMessage.success('修改成功')
        opens.value = false
        emit('changeList')
        deletdId.value = ''
      } else {
        ElMessage.error(res.msg)
      }
    }).finally(() => {
      confirmLoading.value = false
    })
  })
}
const cancel = () => {
  opens.value = false
}
const initData = () => {
  // const id = props.id
  const orderNo = orderNos.value
  fullscreenLoading.value = true
  getOrderDetail(orderNo).then(res => {
    if (res.code == 200) {
      proxy.trajectoryList = res.data
      fullscreenLoading.value = false
    }
  }).catch(() => {
    fullscreenLoading.value = false
  })
  
  listTable({ orderNo }).then(res => {
    if (res.code == 200) {
      // res.data[0].receivingWoodInfo = JSON.parse(res.data[0].receivingWoodInfo)
      updateForm.value = res.data[0]
    }
  })
  initPackage()
}
const xGrid = ref<VxeGridInstance>()
const gridOptions1 = ref({
  border: true,
  showOverflow: true,
  editConfig: {
    trigger: 'click',
    mode: 'cell',
    // 2.3.4.5可点击
    activeMethod({ columnIndex }) {
      if (columnIndex === 3) {
        return true
      }
      if (columnIndex === 4) {
        return true
      }
      if (columnIndex === 5) {
        return true
      }
      if (columnIndex === 2) {
        return true
      }
      return false
    },
  },
  columns: [
    { type: 'seq', title: '序号', width: 50 },
    { field: 'caseNumber', align: 'center', title: '箱号', editRender: {}, width: '180', slots: { edit: 'caseNumber_edit' } },
    { field: 'length', align: 'center', title: '长(cm)', editRender: {}, slots: { edit: 'length_edit' } },
    { field: 'width', align: 'center', title: '宽(cm)', editRender: {}, slots: { edit: 'width_edit' } },
    { field: 'height', align: 'center', title: '高(cm)', editRender: {}, slots: { edit: 'height_edit' } },
    { field: 'weight', align: 'center', title: '实重(kg)', editRender: {}, slots: { edit: 'weight_edit' } },
    { field: 'jweight', align: 'center', title: '计费重', editRender: {}, slots: { edit: 'jWeight_edit' } },
    { field: 'vweight', align: 'center', title: '材积重', editRender: {}, slots: { edit: 'vWeight_edit' } },
    { field: 'site', align: 'center', title: '收货站点', editRender: {}, slots: { edit: 'site_edit' } },
    { field: 'status', align: 'center', title: '状态', editRender: {}, slots: { edit: 'status_edit' } },
    { title: '操作', align: 'center', width: 100, slots: { default: 'operate' } },
  ],

})
const initPackage = () => {
  const orderNoss = orderNos.value
  queryPackageDetailsList({ orderNo: orderNoss }).then(res => {
    tabledata.value = res.data
  })
}
const handleAddPackage = () => {
  const receivingWoodInfo = JSON.parse(JSON.stringify(tabledata.value))
  receivingWoodInfo.push({
    height: '',
    length: '',
    weight: '',
    width: '',
  })
  console.log(receivingWoodInfo)
  proxy.tabledata = receivingWoodInfo
  console.log(proxy.tabledata)
  ElMessage.success('新增成功')
}
const deletdId = ref([])
const removeRowEvent = (row: any, index) => {
  ElMessageBox.confirm('此操作将永久删除该条记录, 是否继续?', '警告', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  }).then(() => {
    const $grid = xGrid.value
    if ($grid) {
      $grid.remove(row)
      deletdId.value.push(row.id)
      console.log(deletdId.value)
      tabledata.value.splice(index, 1)
    }
  })
}
// const getSummaries = (param) => {
//   const { columns } = param
//   const sums = []
//   columns.forEach((column, index) => {
//     if (index === 0) {
//       sums[index] = '合计'
//       return
//     }
//     if (index === 4) {
//       sums[index] = updateForm.value.receivingTotalWeight
//     } else if (index === 5) {
//       sums[index] = updateForm.value.receivingTotalCharging
//     } else if (index === 7) {
//       sums[index] = updateForm.value.receivingTotal
//     } else if (index === 6) {
//       sums[index] = updateForm.value.receivingTotalWood
//     } else {
//       sums[index] = ''
//     }
//   })
//   return sums
// }
const idss = ref([])
const orderNos = ref([])
defineExpose({
  opens,
  title,
  initData,
  loading,
  idss,
  orderNos,
})
</script>
<style lang="less" scoped>
:deep(.el-form-item__content) {
  width: 144px;
}
.footer {
  position: fixed;
  right: 40px;
  bottom: 20px;
  z-index: 50;
}
.notes {
  color: red;
  display: inline-block;
  height: 40px;
  line-height: 40px;
  margin-right: 10px;
}
</style>